package cn.sx.dao;

/*
 *@program:sx_emall_ssm
 *@author: sx
 *@desc: 商品推荐相关dao接口
 *@Time: 2020/9/24  10:18
 */

import cn.sx.entity.Tops;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface TopsDao {

    @Select("select good_id from tops where type = #{type}")
    List<String> selectGoodIdsByType(byte type);

    @Select("select * from tops where good_id = #{goodId} and type = #{type}")
    Tops selectByGoodIdAndType(@Param("goodId") int goodId,@Param("type") byte type);

    @Insert("insert into tops (type,good_id)value(#{type},#{goodId})")
    @SelectKey(keyProperty = "id",statement = "SELECT LAST_INSERT_ID()",
            before = false,resultType = Integer.class)
    boolean insert(Tops tops);

    @Update("delete from tops where id=#{id}")
    boolean delete(int id);

    @Delete("delete from tops where good_id=#{goodId}")
    boolean   deleteByGoodId(int id);

    @Delete("delete  from tops where good_id =#{goodId} and type=#{type}")
    boolean deleteByGoodIdAndType(@Param("goodId") int goodId, @Param("type") byte type);
}
